home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / SUNRPC / SCHED.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-17  |  5.4 KB  |  177 lines

  1. /*
  2.  * linux/include/linux/sunrpc/sched.h
  3.  *
  4.  * Scheduling primitives for kernel Sun RPC.
  5.  *
  6.  * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
  7.  */
  8.  
  9. #ifndef _LINUX_SUNRPC_SCHED_H_
  10. #define _LINUX_SUNRPC_SCHED_H_
  11.  
  12. #include <linux/timer.h>
  13. #include <linux/tqueue.h>
  14. #include <linux/sunrpc/types.h>
  15.  
  16. /*
  17.  * Define this if you want to test the fast scheduler for async calls.
  18.  * This is still experimental and may not work.
  19.  */
  20. #undef  CONFIG_RPC_FASTSCHED
  21.  
  22. /*
  23.  * This is the RPC task struct
  24.  */
  25. struct rpc_task {
  26.     struct rpc_task *    tk_prev;    /* wait queue links */
  27.     struct rpc_task *    tk_next;
  28. #ifdef RPC_DEBUG
  29.     unsigned long        tk_magic;    /* 0xf00baa */
  30. #endif
  31.     struct rpc_task *    tk_next_task;    /* global list of tasks */
  32.     struct rpc_task *    tk_prev_task;    /* global list of tasks */
  33.     struct rpc_clnt *    tk_client;    /* RPC client */
  34.     struct rpc_rqst *    tk_rqstp;    /* RPC request */
  35.     struct rpc_cred *    tk_cred;    /* RPC credentials */
  36.     int            tk_status;    /* result of last operation */
  37.     struct rpc_wait_queue *    tk_rpcwait;    /* RPC wait queue we're on */
  38.  
  39.     /*
  40.      * RPC call state
  41.      */
  42.     __u32            tk_proc;    /* procedure number */
  43.     __u32 *            tk_buffer;    /* XDR buffer */
  44.     void *            tk_argp;    /* argument storage */
  45.     void *            tk_resp;    /* result storage */
  46.     __u8            tk_garb_retry,
  47.                 tk_cred_retry,
  48.                 tk_suid_retry;
  49.  
  50.     /*
  51.      * callback    to be executed after waking up
  52.      * action    next procedure for async tasks
  53.      * exit        exit async task and report to caller
  54.      */
  55.     void            (*tk_callback)(struct rpc_task *);
  56.     void            (*tk_action)(struct rpc_task *);
  57.     void            (*tk_exit)(struct rpc_task *);
  58.     void *            tk_calldata;
  59.  
  60.     /*
  61.      * tk_timer is used for async processing by the RPC scheduling
  62.      * primitives. You should not access this directly unless
  63.      * you have a pathological interest in kernel oopses.
  64.      */
  65.     struct timer_list    tk_timer;    /* kernel timer */
  66.     struct wait_queue *    tk_wait;    /* sync: sleep on this q */
  67.     unsigned long        tk_timeout;    /* timeout for rpc_sleep() */
  68.     unsigned short        tk_flags;    /* misc flags */
  69. #ifdef RPC_DEBUG
  70.     unsigned short        tk_pid;        /* debugging aid */
  71. #endif
  72. };
  73. #define tk_auth            tk_client->cl_auth
  74. #define tk_xprt            tk_client->cl_xprt
  75.  
  76. typedef void            (*rpc_action)(struct rpc_task *);
  77.  
  78. /*
  79.  * RPC task flags
  80.  */
  81. #define RPC_TASK_RUNNING    0x0001        /* is running */
  82. #define RPC_TASK_ASYNC        0x0002        /* is an async task */
  83. #define RPC_TASK_CALLBACK    0x0004        /* invoke callback */
  84. #define RPC_TASK_SWAPPER    0x0008        /* is swapping in/out */
  85. #define RPC_TASK_SETUID        0x0010        /* is setuid process */
  86. #define RPC_TASK_CHILD        0x0020        /* is child of other task */
  87. #define RPC_CALL_REALUID    0x0040        /* try using real uid */
  88. #define RPC_CALL_MAJORSEEN    0x0080        /* major timeout seen */
  89. #define RPC_TASK_ROOTCREDS    0x0100        /* force root creds */
  90. #define RPC_TASK_DYNAMIC    0x0200        /* task was kmalloc'ed */
  91. #define RPC_TASK_KILLED        0x0400        /* task was killed */
  92. #define RPC_TASK_NFSWRITE    0x1000        /* an NFS writeback */
  93.  
  94. #define RPC_IS_RUNNING(t)    ((t)->tk_flags & RPC_TASK_RUNNING)
  95. #define RPC_IS_ASYNC(t)        ((t)->tk_flags & RPC_TASK_ASYNC)
  96. #define RPC_IS_SETUID(t)    ((t)->tk_flags & RPC_TASK_SETUID)
  97. #define RPC_IS_CHILD(t)        ((t)->tk_flags & RPC_TASK_CHILD)
  98. #define RPC_IS_SWAPPER(t)    ((t)->tk_flags & RPC_TASK_SWAPPER)
  99. #define RPC_DO_CALLBACK(t)    ((t)->tk_flags & RPC_TASK_CALLBACK)
  100. #define RPC_DO_ROOTOVERRIDE(t)    ((t)->tk_flags & RPC_TASK_ROOTCREDS)
  101. #define RPC_ASSASSINATED(t)    ((t)->tk_flags & RPC_TASK_KILLED)
  102.  
  103. /*
  104.  * RPC synchronization objects
  105.  */
  106. struct rpc_wait_queue {
  107.     struct rpc_task *    task;
  108. #ifdef RPC_DEBUG
  109.     char *            name;
  110. #endif
  111. };
  112.  
  113. #ifndef RPC_DEBUG
  114. # define RPC_INIT_WAITQ(name)    ((struct rpc_wait_queue) { NULL })
  115. #else
  116. # define RPC_INIT_WAITQ(name)    ((struct rpc_wait_queue) { NULL, name })
  117. #endif
  118.  
  119. /*
  120.  * Function prototypes
  121.  */
  122. struct rpc_task *rpc_new_task(struct rpc_clnt *, rpc_action, int flags);
  123. struct rpc_task *rpc_new_child(struct rpc_clnt *, struct rpc_task *parent);
  124. void        rpc_init_task(struct rpc_task *, struct rpc_clnt *,
  125.                     rpc_action exitfunc, int flags);
  126. void        rpc_release_task(struct rpc_task *);
  127. void        rpc_killall_tasks(struct rpc_clnt *);
  128. void        rpc_execute(struct rpc_task *);
  129. void        rpc_run_child(struct rpc_task *parent, struct rpc_task *child,
  130.                     rpc_action action);
  131. int        rpc_add_wait_queue(struct rpc_wait_queue *, struct rpc_task *);
  132. void        rpc_remove_wait_queue(struct rpc_task *);
  133. void        rpc_sleep_on(struct rpc_wait_queue *, struct rpc_task *,
  134.                     rpc_action action, rpc_action timer);
  135. void        rpc_cond_wait(struct rpc_wait_queue *, struct rpc_task *,
  136.                     unsigned char *,
  137.                     rpc_action action, rpc_action timer);
  138. void        rpc_wake_up_task(struct rpc_task *);
  139. void        rpc_wake_up(struct rpc_wait_queue *);
  140. struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *);
  141. void        rpc_wake_up_status(struct rpc_wait_queue *, int);
  142. void        rpc_add_timer(struct rpc_task *, rpc_action);
  143. void        rpc_del_timer(struct rpc_task *);
  144. void        rpc_delay(struct rpc_task *, unsigned long);
  145. void *        rpc_allocate(unsigned int flags, unsigned int);
  146. void        rpc_free(void *);
  147. int        rpciod_up(void);
  148. void        rpciod_down(void);
  149. void        rpciod_wake_up(void);
  150. void        rpciod_tcp_dispatcher(void);
  151. #ifdef RPC_DEBUG
  152. void        rpc_show_tasks(void);
  153. #endif
  154.  
  155. extern __inline__ void *
  156. rpc_malloc(struct rpc_task *task, unsigned int size)
  157. {
  158.     return rpc_allocate(task->tk_flags, size);
  159. }
  160.  
  161. extern __inline__ void
  162. rpc_exit(struct rpc_task *task, int status)
  163. {
  164.     task->tk_status = status;
  165.     task->tk_action = NULL;
  166. }
  167.  
  168. #ifdef RPC_DEBUG
  169. extern __inline__ char *
  170. rpc_qname(struct rpc_wait_queue *q)
  171. {
  172.     return q->name? q->name : "unknown";
  173. }
  174. #endif
  175.  
  176. #endif /* _LINUX_SUNRPC_SCHED_H_ */
  177.